package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.*;

import riverlayout.component.*;

/**
 * 18-01-2010
 * 
 * This window views the about.
 * 
 * @author Michel Rondhuis
 */
public class AboutView extends JPanel {

	private static final long serialVersionUID = 1L;

	private static JFrame frame;

	private JPanel rightPanel = new JPanel();
	private JPanel leftPanel = new JPanel();
	URL url = null;
	URL urlIcon = null;

	//button.setIcon(new ImageIcon(url));

	private ImageIcon image;

	private JLabel aboutLabel = new JLabel("About");
	private JLabel pictureLabel = null;

	private JButton okButton = new JButton("Ok");

	/**
	 * This is the setup of the window.
	 */
	public AboutView(){

		try {
			url = getClass().getClassLoader().getResource("pics/GidaiAbout.jpg");
			image = new ImageIcon(url);
			pictureLabel = new JLabel(image);

			urlIcon = getClass().getClassLoader().getResource("pics/icon.jpg");
		} catch(NullPointerException x) {
			x.printStackTrace();
			throw x;
		}

		// Setup of frame.
		frame = new JFrame();
		frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		frame.setSize(380, 270);
		frame.setContentPane(this);
		frame.requestFocus();
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setTitle("About");
		frame.setIconImage(new ImageIcon(urlIcon).getImage());

		// Setup of elements.
		pictureLabel.setSize(100, 100);
		okButton.addActionListener(new okButtonHandler());

		// Adding all the elements starts here.
		setLayout(new RiverLayout());
		leftPanel.setLayout(new RiverLayout());
		rightPanel.setLayout(new RiverLayout());

		add("left vtop vfill", leftPanel);
		add("tab hfill vfill", rightPanel);

		leftPanel.add("left vtop",pictureLabel);
		leftPanel.add("br", new JLabel("Gidai \u00a9"));
		leftPanel.add("br", new JLabel("Versie 1.0"));
		leftPanel.add("br", new JLabel("Project groep: EIN1Va"));

		rightPanel.add("left", aboutLabel);
		rightPanel.add("br", new JLabel("Gemaakt door:"));
		rightPanel.add("br", new JLabel("Dave Nieuwenhuijzen"));
		rightPanel.add("br", new JLabel("Stijn Kliemesch"));
		rightPanel.add("br", new JLabel("Martijn Scholten"));
		rightPanel.add("br", new JLabel("Timo Janssen"));
		rightPanel.add("br", new JLabel("Maarten Ezendam"));
		rightPanel.add("br", new JLabel("Erwin Cavas"));
		rightPanel.add("br", new JLabel("Michel Rondhuis"));
		rightPanel.add("br", okButton);
	}

	class okButtonHandler implements ActionListener {
		/**
		 * Hides the window
		 */
		public void actionPerformed(ActionEvent arg0) {
			frame.setVisible(false);
		}
	}
}